#include <stdio.h> 
int main(){
	int n,i,j;
	scanf("%d",&n);
	int arr[n],max = -1,res;
	for( i=0;i<n;i++){
		scanf("%d",&arr[i]);
	}
	
    for( i=0;i<n;i++){
		int count=0;
		for( j=0;j<n;j++)
		{
			if(arr[i] == arr[j])
			{
				count++;
			} 
		} 
		if(count>max)
		{
			max = count;
			res = arr[i];
		}
	}
	printf("%d %d",res,max);
	return 0;
}
